perm filename TEST.2[P,JRA]1 blob
sn#155753 filedate 1975-04-23 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 CIS 280 torture no. 2
C00012 ENDMK
C⊗;
CIS 280 torture no. 2
Evaluate the following. Write in list-notation wherever possible.
1. cdr[(A B)]
2. (CAR (QUOTE A))
3. cons[A;(B)]
4. cons[atom[ATOM];eq[EQ;(A)]]
5. list[A;B;C]
6. list[A;()]
7. concat[A;(B,C)]
8. append[(A B C); (1 2)]
9. append[A;()]
10. [eq[A;A]→1; T→2]
11. null[()]
12. λ[[x;y]cadr[y]][cons[A;eq[A;B]];(A .(B . C))]
13. λ[[x;y]cadr[y]][cons[A;eq[A;(B . C)]];(A .(B . C))]
True-false (told you!!)
14. for any LISP computation: car[cons[x;y]] = x.
15. for any LISP computation: car[cons[x;Y]] = x.
16. for any LISP computation: [eq[x;y]→ 1; T → 1] = 1
17. for any LISP computation: atom[atom[cons[A;B]]] = T
Define the following terms. Be concise but be precise.
18. call-by-value
19. compilation
20. hashing function
21. stack
22. access environment
23. binary tree
24. total function
25. property list
26-27. garbage collection
sweep phase
mark phase
Fill in the blanks.
28.-33.
In a _________ binding scheme we use a name-value stack and post the binding of variables
in the stack. When we want to find the value of a variable we use a ________ search down
the name stack, looking for an occurrence of the variable name. This scheme loses when we
want to allow function-valued variables. In this case, a stack discipline is not
sufficiently general and we segment the "stack" using access and _______ environment
pointers. An alternative binding scheme, called __________ binding, replaces the
name-value stack with a single symbol table. Here we post the values of variable in a
______ -cell. This scheme has an advantage in lookup speed. Here, all atoms are
represented as pointers to their symbol-table entries. This scheme is effective since the
LISP reader makes sure that atoms are stored __________. This scheme also has difficulty
if we wish to use the full generality of functional arguments.
34.-39.
One of the more powerful programming techniques is abstraction. In data-structure
programming this is made manifest by describing structures as representation independent
as possible (without losing significant facets of the problem). We think of structures in
terms of at least three operations: ___________, _________, and ____________. One the
abstract algorithm is suitably described then we can think about representations for the
abstract operations. When defining procedures (or functions) in LISP we use a notational
device based on the _______________ for displaying the formal parameters (or arguments).
The typical structure of a algorithmic definition in LISP is a ____________definition.
The body of such a definition is a a conditional expression describing the computations to
be performed depending on the structure of one or more of the inputs. One or more of the
tests in the conditional should involve _________________ to insure that the computations
halt for at least some inputs.
40.-47.
When we come to the implementation of LISP's data structures we must concoct
representations for S-expressions. A typical memory layout will contain two storage areas
for components on LISP's structures. The __________ area will contain quantities like
numbers and the print-names for atoms. The other area, called _______________ will
contain representations of _________________. The storage management problems of LISP
tend to become quite complex. Thus instead of leaving such questions up to the user, LISP
handles its own storage requirements. This is done as follows: all un-used cells in the
two areas of LISP memory are chained together by their cdr-parts. (the general term for
such "LISP-type lists is ___________) Now most of the LISP primitive operations are simply
________-manipulation operations; they make no demands on storage. However ____ is
different; this operation must effectively create a new cell. The new cell is taken off
the ___________ list. If this list is non-empty we win and by jiggling pointers we can
perform the desired operation. However if the list is empty, we call the
____________________.
48.-50.
One of the novel features of LISP is its use of an evaluator or _____________ as part of
its running environment. Basically, LISP expressions which we want evaluated are
represented as data structures and are presented to the evaluator. The evaluator operates
on the representation of the expression and finally produces the answer. There are
several advantages to this scheme of things. First, the evaluation process can be
described as a LISP function, thus giving a concise and precise desciption of the meaning
of the constructs of the language. Also, since the evalautor is always available as a
LISP function, we can call it during a computation. This allows us to generate data
structures during a computation and then cause them to be evaluated. This facility is
quite useful in an on-line programming environment where we are editing and debugging
programs (i.e. looking on them as data objects) and finally running pieces of program
(i.e. looking on them as program) Most languages, like ________, supply compilers to take
the source language constructs into machine language code. LISP compilers are also
available. They are universally written in LISP and then asked to compile themselves.
This process is called __________________.
Given the following definition
whotakrok[x] <= [atom[cdr[cons[FOO;x]]]→ cadr[(A B C D F)];
T → caddr[(A B C D F)]]
Perform the following computation. Pick the first letter of your last name and use that
at the input to a call on "whotakrok". (The final value is the lowest grade which the
turkey sitting next to you can receive for 280 (this course, dummy).)